extends Card


func play_on_release(card_view: CardView) -> void:
	var monster: Monster = Globals.current_monster
	var player = card_view.get_tree().get_first_node_in_group("player")
	player.play_animation("attack")
	if CardManager.round_data.attack_times >= self.attack_times:
		self.point = self.origin_point - self.reduce_point
	var tween := card_view.create_tween()
	tween.tween_callback(Shake.shake.bind(monster, 16, 0.3))
	tween.tween_callback(
		func(): Events.take_damage.emit(player, monster, get_final_damage(monster.state))
	)
	tween.tween_interval(0.31)
	await tween.finished
	player.play_animation("default")
	card_view.play_on_release_signal_finish.emit()



func update_attribute():
	if CardManager.round_data.attack_times >= self.attack_times:
		self.point = self.origin_point - self.reduce_point


func get_desc() -> String:
	if desc_lab == "":
		return ""
	var text = desc_lab % [get_final_damage_str(null), self.attack_times, self.reduce_point]
	return text


func get_desc_on_target(target: Monster) -> String:
	return desc_lab % [get_final_damage_str(target.state), self.attack_times, self.reduce_point]


func init_from_csv(introduce):
	super.init_from_csv(introduce)
	self.damage = int(introduce[5])
	self.attack_times = int(introduce[6])
	self.reduce_point = int(introduce[7])
